package com.hyb.algorithm.data.struct.list;

/**
 * @Author: huyanbing
 * @Date: 2021/8/14 7:22 下午
 */
public class FindMid {

    public static void main(String[] args) {

    }


    public ListNode findMid(ListNode head) {

        if(head==null||head.next==null){

            return head;

        }

        ListNode slow = head;
        ListNode fast = head;

        while (fast != null && fast.next != null) {
            slow = slow.next;
            fast = fast.next.next;
        }

        return slow;
    }
}
